package topofstack.networkserverutils.bean;

public class Location {
	public final int latDegree;
	public final int latMinute;
	public final double latSecond;
	public final String latDirection; 
	
	public final int longDegree;
	public final int longMinute;
	public final double longSecond;
	public final String longDirection;
	
	public Location(int latDegree, int latMinute, double latSecond, String latDirection,
			int longDegree, int longMinute, double longSecond, String longDirection) {
		this.latDegree = latDegree;
		this.latMinute = latMinute;
		this.latSecond = latSecond;
		this.latDirection = latDirection;
		
		this.longDegree = longDegree;
		this.longMinute = longMinute;
		this.longSecond = longSecond;
		this.longDirection = longDirection;
	}
	
	public double getLatitude() {
		double latitude = latDegree;
		latitude += (latMinute + latSecond / 60) / 60;
		if(!latDirection.contains("N"))
			latitude = -latitude;
		return latitude;
	}
	
	public double getLongitude() {
		double longitude = longDegree;
		longitude += (longMinute + longSecond / 60) / 60;
		if(!longDirection.contains("E"))
			longitude = -longitude;
		return longitude;
	}

	@Override
	public String toString() {
		return latDegree + " " + latMinute
				+ " " + latSecond + " " + latDirection
				+ "\n" + longDegree + " " + longMinute
				+ " " + longSecond + " " + longDirection;
	}
}
